// 普通写法
class C {
  name: string;
  age: number;
  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
  }
}
class D extends C {
  sex: string;
  constructor(name: string, age: number, sex: string) {
    super(name, age);
    this.sex = sex;
  }
}

// 简化写法
// 直接将属性定义在构造函数中，不用再写属性声明和构造函数中的属性初始化
class F {
  //构造函数参数必须写上属性修饰符和类型，否则报错
  constructor(public name: string, public age: number) {}
}
class E extends F {
  constructor(name: string, age: number, public sex: string) {
    super(name, age);
  }
}
const e = new E("Tom", 18, "male");
console.log(e); // E { name: 'Tom', age: 18, sex: 'male' }
